package IteratorAndComposite.entry;

import IteratorAndComposite.IteratorInterfaces.Menu;

import java.util.HashMap;
import java.util.Iterator;

/**
 * @Author: pengzx
 * @Description:
 * @Date: 16:09 2017/9/21
 * @Modified by: 1.0
 */
public class CafeMenu implements Menu {
    HashMap cafeMenu;

    public CafeMenu()
    {
        cafeMenu = new HashMap(0);
        addItem("牛奶咖啡","牛奶加咖啡",false,1.99);
        addItem("柠檬咖啡","柠檬加咖啡",true,0.99);
        addItem("果冻咖啡","果冻加咖啡",false,2.99);
        addItem("摩卡咖啡","摩卡加咖啡",false,3.99);
    }

    public void addItem(String name, String destription, boolean vegetarian, double price)
    {
        MenuItem menuItem = new MenuItem(name, destription, vegetarian, price);
        cafeMenu.put(menuItem.getName(), menuItem);
    }

    @Deprecated
    public HashMap getCafeMenu()
    {
        return cafeMenu;
    }

    @Override
    public Iterator createIterator()
    {
        return cafeMenu.values().iterator();
    }
}
